<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/9/8 0008
 * Time: 下午 11:22
 */

defined('BASEPATH') OR exit('No direct script access allowed');
 ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>会员注册-有点</title>
    <link rel="stylesheet" type="text/css" href="<?php echo base_url()?>public/admin/css/css.css" />
    <script src="https://cdn.bootcss.com/jquery/1.12.4/jquery.js"></script>
    <style>

        .backFile{
            text-indent: 58px;
            padding-top: 15px;
            /*border: 1px;*/
        }

    </style>
</head>
<body>
<div id="pageAll">
    <div class="pageTop">
        <div class="page">
            <img src="<?php echo base_url()?>public/admin/img/coin02.png" />
            <span>
                <a href="#">首页</a>&nbsp;-&nbsp;
                <a href="#">公共管理</a>&nbsp;-
            </span>&nbsp;添加会员
        </div>
    </div>
    <div class="page ">
        <!-- 会员注册页面样式 -->
        <div class="banneradd bor">
            <div class="baTopNo">
                <span>添加会员</span>
            </div>
        <form action="<?=site_url()?>/admin/userManage/addUser" method="post" >
            <div class="baBody">
                <div class="bbD">
                    &nbsp;用户名：<input type="text" class="input3" name="username" />
                </div>
                <div class="bbD">
                    &nbsp;&nbsp;&nbsp;&nbsp;密码：
                    <input type="password" class="input3" name="pwd" />
                </div>
                <div class="bbD">
                    手机号码:<input type="text" class="input3" name="mobile" />
                </div>

                <div class="bbD">
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;地址：
                    <select name="province" id="province">
                        <option value="" >请选择省</option>
                    <?php foreach($pro_data as $v ):?>
                        <option value="<?=$v['areaid']?>" ><?=$v['areaname']?></option>
                    <?php endforeach;?>
                    </select>
                    <select name="city" id="city">
                        <option value="">请选择市</option>
                    </select>
                    <select name="country" id="country">
                        <option value="">请选择区/县</option>
                    </select>
                </div>

                <div class="bbD" >
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;头像:
                    <input type="file" name='file' class="myfile" />
                    <input type="hidden" name="myfile" style="" class="filePath" >
                   <!-- <button class="buttonFile">上传头像</button>-->
                    <div class="backFile"></div>
                </div>

                <div class="bbD">
                    <p class="bbDP">
                        <input type="submit" class="btn_ok btn_yes">
                        <input type="reset" class="btn_ok btn_no">
<!--                        <a class="btn_ok btn_yes" href="#">提交</a>
                        <a class="btn_ok btn_no" href="#">取消</a>-->
                    </p>
                </div>
            </div>
        </form>
        </div>
        <!-- 会员注册页面样式end -->
    </div>

</div>
</body>
<script>
    $(function()
    {
        //图片上传
        $('.myfile').click(function()
        {
            //alert(123);return ;
            var selectedFile = $('.myfile').get(0).files[0];
            var jsonData = new FormData();
            jsonData.append('file',selectedFile);
            //console.log(jsonData);
            $.ajax({
                url:"<?=site_url('admin/userManage/imgUpload')?>",
                type:'post',
                dataType:'json',
                data:jsonData,
                processData:false,
                contentType:false,
                success:function(ret)
                {
                    //console.log(ret);
                    if(ret.status=='success')
                    {
                        var con = "<img src="+ret.message+" name='headImg'  >";
                        //console.log(con);
                        $('.backFile').html(con);
                        $('.filePath').val(ret.message);
                    }

                    if(ret.status=='false')
                    {
                        alert(ret.message);
                    }
                }
            })

        })
        //选择省,获取市
        $('#province').change(function()
        {
            //获取当前省的id
            var id = $(this).val();
            $.ajax({
                url:"<?=base_url()?>index.php/admin/userManage/addUser",
                type:'get',
                dataType:'json',
                data:{
                    'type':'city',
                    'id':id
                }
            })
            .done(function(ret)
            {
                if(ret.status=='success')
                {
                    $('#city').html(ret.message);
                }
            })
        })

        //选择市,获取县.区
        $('#city').change(function()
        {
            var id = $(this).val();
            $.ajax({
                url:"<?=base_url()?>index.php/admin/userManage/addUser",
                type:'get',
                dataType:'json',
                data:{
                    'type':'country',
                    'id':id
                }
            })
            .done(function(ret)
            {
                if(ret.status=='success')
                {
                    $('#country').html(ret.message);
                }
            })

        })



    })

</script>
</html>
